﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;

namespace QL_NOI_TRU
{
    public partial class frmCapNhatPhieuDieuTri : DevExpress.XtraEditors.XtraForm
    {
        public frmCapNhatPhieuDieuTri()
        {
            InitializeComponent();
        }

        private void btThem_Click(object sender, EventArgs e)
        {
            var f = new frmYeuCauXetNghiem();
            f.Show();
        }

        private void frmCapNhatPhieuDieuTri_Load(object sender, EventArgs e)
        {
            // đổ dữ liệu vào cbbMaBenhAn
            var maBA = "select MABENHAN from BENH_AN";
            SqlConnection conn = new SqlConnection(frmDangnhap.stringConn);
            SqlCommand cm = conn.CreateCommand();
            cm.CommandText = maBA;
            conn.Open();
            SqlDataReader dr = cm.ExecuteReader();
            while (dr.Read())
            {
                var newVariable = cbbMaBenhAn.Properties.Items.Add(String.Format("{0}", dr["MABENHAN"]));
            }
            dr.Close();
        }

        private void cbbMaBenhAn_SelectedIndexChanged(object sender, EventArgs e)
        {
            // đổ dữ liệu vào cbbNguoiDieuTri
            var m = "select MA_NV,HOTEN from NHAN_VIEN";
            SqlConnection conn = new SqlConnection(frmDangnhap.stringConn);
            SqlCommand cm = conn.CreateCommand();
            cm.CommandText = m;
            conn.Open();
            SqlDataReader dr = cm.ExecuteReader();
            while (dr.Read())
            {
                var newVariable = cbbBSDieuTri.Properties.Items.Add(String.Format("{0} | {1}", dr["MA_NV"],dr["HOTEN"]));
            }
        }

        private void cbbMaBenhAn_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                tbMAPhieuDieuTri.Focus();
        }

        private void tbMAPhieuDieuTri_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                cbbBSDieuTri.Focus();
        }

        private void cbbBSDieuTri_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                cbbngaylap.Focus();
        }

        private void cbbngaylap_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txtMach.Focus();
        }

        private void txtMach_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txtNhietDo.Focus();
        }

        private void txtNhietDo_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txtHuyetAp.Focus();
        }

        private void txtHuyetAp_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txtNhipTho.Focus();
        }

        private void txtNhipTho_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                meYLenh.Focus();
        }

        private void meYLenh_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                meDienBienBenh.Focus();
        }

        private void meDienBienBenh_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txtChanDoan.Focus();
        }

        private void txtChanDoan_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txtKetQuaXN.Focus();
        }

        private void txtKetQuaXN_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                cbbLuu.Focus();
        }
    }
}